<?php
defined('_JEXEC') or die('Restricted access');
$img_dir = JPATH_SITE.DIRECTORY_SEPARATOR.'images'.DIRECTORY_SEPARATOR.'fileupload'.DIRECTORY_SEPARATOR;
$img_path = JURI::root(true).'/images/fileupload/';
$title = ($this->id)?"Sửa khách hàng":"Thêm khách hàng mới";
?>
<div class='tab_content' id="tab_create_customer">
	<div class='container-fluid container_root margin10'>
		<div class='row-fluid'>
			<div class='widget widget-padding span12'>
				<div class='widget-header'>
					<i class="icon-plus"></i>
					<h5><?php echo $title ?></h5>
				</div>
				<div class='widget-body'>
								
					<form class='form' id="form_create_customer" method="post" action="index.php">
						<div class='row-fluid'>
							<div class='span12'>
								<button type="submit" class='btn btn-primary'>
									<i class='icon-ok icon-white'></i>
									<?php echo JText::_("COM_KETNOI_SAVEBTN") ?>
								</button>
								
								<a type="submit" href="#customer" class='btn'>
									<i class='icon-reorder icon-white'></i>
									Danh sách
								</a>
							</div>
						</div>
						
						<div class="row-fluid margin10">
							<div class='span12'>
								<div class="row-fluid">
									<div class='span4'>
										<div class="control-group">
				                          	<label class="control-label" for="name">
				                          		<?php echo JText::_("COM_KETNOI_CODE") ?>
												<em>*</em>
											</label>
					                        <div class="controls row-fluid">
					                            <input type='text' value='<?= $this->row->ma ?>' required='required' name='ma' class="span12"/>
					                       		<?php if($this->id): ?>
					                       			<input type='hidden' id='oldma' value='<?= $this->row->ma ?>' /> 
					                       		<?php endif; ?>
					                        </div>
				                        </div>
									</div>
									
									<div class='span4'>
										<div class="control-group">
				                          	<label>
												Mã số thuế
											</label>
					                        <div class="controls row-fluid">
					                            <input value='<?= $this->row->masothue ?>' type='text' name='masothue' class="span12"/>
					                        </div>
				                        </div>
									</div>
									
									<div class='span4'>
										<div class="control-group">
				                          	<label>
												Fax
											</label>
					                        <div class="controls row-fluid">
					                            <input value='<?= $this->row->fax ?>' type='text' name='fax' class="span12"/>
					                        </div>
				                        </div>
									</div>
								</div>
								
								<div class="row-fluid">
									<div class='span4'>
										<div class="control-group">
				                          	<label>
												Tên khách hàng / Tên đơn vị
												<em>*</em>
											</label>
					                        <div class="controls row-fluid">
					                            <input value='<?= $this->row->ten ?>' type='text' required='required' name='ten' class="span12"/>
					                        </div>
				                        </div>
									</div>
									
									<div class='span4'>
										<div class="control-group">
				                          	<label>
												Điện thoại
											</label>
					                        <div class="controls row-fluid">
					                            <input value='<?= $this->row->dienthoai ?>' type='text' name='dienthoai' class="span12"/>
					                        </div>
				                        </div>
									</div>
									
									<div class='span4'>
										<div class="control-group">
				                          	<label>
												Email
											</label>
					                        <div class="controls row-fluid">
					                            <input value='<?= $this->row->email ?>' type='text' name='email' class="span12"/>
					                        </div>
				                        </div>
									</div>
									   
								</div>
								
								<div class="row-fluid">
									<div class='span4'>
										<div class="control-group">
				                          	<label>
												Tên người liên hệ
											</label>
					                        <div class="controls row-fluid">
					                            <input value='<?= $this->row->nguoilienhe ?>' type='text' name='nguoilienhe' class="span12"/>
					                        </div>
				                        </div>
									</div>
									
									<div class='span4'>
										<div class="control-group">
				                          	<label>
												Điện thoại
											</label>
					                        <div class="controls row-fluid">
					                            <input value='<?= $this->row->dienthoailienhe ?>' type='text' name='dienthoailienhe' class="span12"/>
					                        </div>
				                        </div>
									</div>
									
									<div class='span4'>
										<div class="control-group">
				                          	<label>
												Email
											</label>
					                        <div class="controls row-fluid">
					                            <input value='<?= $this->row->emaillienhe ?>' type='text' name='emaillienhe' class="span12"/>
					                        </div>
				                        </div>
									</div>
									   
								</div>
								
								<div class="row-fluid">
									<div class='span4'>
										<div class="control-group">
				                          	<label class="control-label" for="name">
				                          		Địa chỉ thanh toán
											</label>
					                        <div class="controls row-fluid">
					                        	<textarea name='diachithanhtoan' class="span12"><?= $this->row->diachithanhtoan ?></textarea>
					                        </div>
				                        </div>
									</div>
									
									<div class='span4'>
										<div class="control-group">
				                          	<label class="control-label" for="name">
				                          		Địa chỉ giao nhận
											</label>
					                        <div class="controls row-fluid">
					                        	<textarea name='diachigiaonhan' class="span12"><?= $this->row->diachigiaonhan ?></textarea>
					                        </div>
				                        </div>
									</div>
									
									<div class='span4'>
										<div class="control-group">
				                          	<label class="control-label" for="name">
				                          		Mô tả
											</label>
					                        <div class="controls row-fluid">
					                        	<textarea name='mota' class="span12"><?= $this->row->mota ?></textarea>
					                        </div>
				                        </div>
									</div>									 
								</div>
							</div>
						</div>
						
						<input type="hidden" name="option" value="com_ketnoi" />
						<input type="hidden" name="view" value="customer" />
						<input type="hidden" name="task" value="customer.save" />
						<input type="hidden" name="layout" value="create" />
						<input type="hidden" name="tmpl" value="raw" />
						<input type="hidden" name="quickcreate" value="<?= JRequest::getVar("quickcreate",0) ?>" />
						<input type="hidden" name="client_update" value="<?= JRequest::getVar("client_update","") ?>" />
						<?php if($this->id): ?>
						<input type="hidden" name="id" value="<?= $this->id ?>" />
						<?php endif; ?>
					</form>
				</div>
				
			</div>
		</div>
	</div>
</div>

<script>
	<?php if($this->id): ?>
		setHash("edit_customer",<?= json_encode(array("id"=>$this->id)) ?>);
	<?php endif; ?>
</script>